package cn.monkey.transport.netty.server.codec.protocol.tcp.mqtt;

import cn.monkey.transport.netty.server.codec.protocol.AbstractServerProtocolRouterFunction;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;

import java.util.function.BiPredicate;
import java.util.function.Consumer;

public class MqttServerProtocolRouterFunction extends AbstractServerProtocolRouterFunction {

    public MqttServerProtocolRouterFunction(BiPredicate<Channel, ByteBuf> predicate,
                                            MqttServerProtocolConfig mqttServerConfig,
                                            Consumer<Channel> consumer) {
        super(MqttServerProtocolPredicate.INSTANCE.and(predicate), ((MqttServerProtocolConsumer) () -> mqttServerConfig).andThen(consumer));
    }

    public MqttServerProtocolRouterFunction(MqttServerProtocolConfig mqttServerProtocolConfig,
                                            Consumer<Channel> consumer) {
        super(MqttServerProtocolPredicate.INSTANCE, ((MqttServerProtocolConsumer) () -> mqttServerProtocolConfig).andThen(consumer));
    }

    public MqttServerProtocolRouterFunction(BiPredicate<Channel, ByteBuf> predicate, Consumer<Channel> consumer) {
        super(MqttServerProtocolPredicate.INSTANCE.and(predicate), MqttServerProtocolConsumer.INSTANCE.andThen(consumer));
    }

    public MqttServerProtocolRouterFunction(Consumer<Channel> consumer) {
        super(MqttServerProtocolPredicate.INSTANCE, MqttServerProtocolConsumer.INSTANCE.andThen(consumer));
    }
}